import java.util.Scanner;
public class P1980 {
    public static void main(String args[]){
        int number_count,n;
        int count = 0;
        Scanner sc = new Scanner(System.in);
        number_count = sc.nextInt();
        n = sc.nextInt();

        for (int i = 1; i <=number_count ;i++){
            int m  = i;
            while (m != 0){
                if (m % 10 == n){
                    count++;
                    m /= 10;
                }
                else {
                    m /= 10;
                }
            }
        }
        System.out.println(count);
    }
}
